{template 'common/header'}
<ul class="we7-page-tab">
    <li class="active">
        <a href="javacript:void(0)">云服务管理</a>
    </li>
</ul>
<div class="clearfix">
    {if isset($auth)}
        <table class="table table-hover we7-table table-form vertical-middle">
            <tbody>
            <tr>
                <th colspan="2" class="text-left">
                    绑定信息
                </th>
            </tr>
            <tr>
                <td>
                    授权站点
                </td>
                <td>
                    {$auth['referrer']}
                </td>
            </tr>
            <tr>
                <td>
                    用户名
                </td>
                <td>
                    {$auth['username']}
                </td>
            </tr>
            <tr>
                <td>
                    站点ID
                </td>
                <td>
                    {$auth['appid']}
                </td>
            </tr>


            <tr>
                <td>
                    站点密钥
                </td>
                <td>
                    {$auth['appsecret']}
                </td>
            </tr>
            <tr>
                <th colspan="2" class="text-left">
                    <div></div>
                    <input name="submit" id="bind" value="重新绑定" class="btn btn-primary span3" type="button"/>
                </th>
            </tr>

            </tbody>
        </table>
        {/if}
        <form action="{url 'site/entry/dashboard_auth' array('m'=>'diygwcom_app')}" method="post" id="auth-form" class="we7-form  {if isset($auth)}hide{/if}" role="form">
            <div class="form-group" >
                <label class="col-sm-2 control-label">用户名</label>
                <div class="col-sm-8">
                    <input name="username" class="form-control" value="" type="text">
                    <div class="help-block">绑定DIY官网用户名</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">密码</label>
                <div class="col-sm-8">
                    <input name="password" class="form-control" value="" type="password">
                    <div class="help-block">绑定DIY官网密码</div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-8">
                    <input name="submit" id="submit" value="绑定" class="btn btn-primary span3" type="button"/>
                </div>
            </div>
            <div>如果还没有用户，请点击<a href="http://www.diygw.com" target="_blank" style="color: #ff0000;">DIY官网http://www.diygw.com进行注册</a></div>
        </form>
</div>
<script>

    $("#bind").click(function () {
        $("#auth-form").removeClass("hide");
        var scrollHeight = $('#auth-form').prop("scrollHeight");
        $("html,body").animate({scrollTop:scrollHeight+200}, 400);
        $('input[name="username"]').focus();
    })
    $("#submit").click(function () {
        var cansubmit = true;
        if (cansubmit) {
            cansubmit=false;
            $.post($('#auth-form').attr('action'), $('#auth-form').serialize(), function (res) {
                cansubmit = true;
                if (res.type == 'error') {
                    util.message(res.message, '', 'error');
                } else {
                    util.message(res.message, location.href, 'success');
                }
            }, 'json').error(function (error) {
                cansubmit = true;
                util.message('保存出错,请重试', '', 'error');
            })
        }
    })
</script>
{template 'common/footer'}